package com.hecore.lagou.work;

import com.hecore.lagou.util.CommonSettingUtil;
import com.hecore.lagou.work.entity.SortNumBean;
import com.hecore.lagou.work.sort.SortNumMapper;
import com.hecore.lagou.work.sort.SortNumReducer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;

import java.io.IOException;


/**
 * @Author: hecore
 * @Date: 2020/10/18 23:24
 * @Description: 作业启动Driver
 */

public class SortNumDriver {

    /**
     *   1.1 Job Define-Single Instance
     *   1.2 Job Config
     *   1.3 Common Out Setting
     * @param args
     */
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Configuration config=new Configuration();
        Job job=Job.getInstance(config,"sort-num");
        setJobConfig(job);
        String inputPath="F:/book/work/";
        String outPtah="F:/book/sortout";
        CommonSettingUtil.setLocalOut(job,inputPath,outPtah);
    }

    //  SortNumBean, NullWritable
    private static void setJobConfig(Job job) {
        job.setJarByClass(SortNumDriver.class);
        job.setMapperClass(SortNumMapper.class);
        job.setReducerClass(SortNumReducer.class);
        job.setMapOutputKeyClass(SortNumBean.class);
        job.setMapOutputValueClass(NullWritable.class);
        job.setOutputKeyClass(NullWritable.class);
        job.setOutputValueClass(SortNumBean.class);
        job.setNumReduceTasks(1);
        job.setJobName("SortNum");
    }

}
